<template>
  <div>
    <div class="head-title-warp">
      <div class="head-title-left">
        <div class="title-left-bg">
          <img src="../../../../assets/solarPower/dizhi.svg" />
        </div>
        <div class="title-left-word">{{ pageData.plantAddress }}</div>
      </div>
      <div class="head-title-right">
        <!-- <div class="title-right-box1">
          <el-image :src="require('@/assets/solarPower/dizhi.svg')" fit="fill" />
          多云
        </div> -->
        <div class="title-right-box2">
          <!-- <div style="height: 36px; line-height: 36px">
            <span>21~26℃</span>&nbsp;&nbsp;
            <span>广州</span>
          </div> -->
          <div>{{ date }}</div>
        </div>
        <!-- <div>3</div>
        <div>4</div> -->
      </div>
    </div>
    <div class="head-title-center">
      <el-row :gutter="10">
        <el-col :span="6">
          <div class="center-box">
            <div>
              <el-image :src="require('@/assets/solarPower/dangri.png')" fit="fill" />
            </div>
            <div style="margin-left: 10px">
              <div>
                <span>{{ pageData.day_power }}</span> (kWh)
              </div>
              <div>当日发电量</div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="center-box">
            <div>
              <el-image :src="require('@/assets/solarPower/leiji.png')" fit="fill" />
            </div>
            <div style="margin-left: 10px">
              <div>
                <span>{{ pageData.month_power }}</span> (kWh)
              </div>
              <div>当月发电量</div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="center-box">
            <div>
              <el-image :src="require('@/assets/solarPower/riyong.png')" fit="fill" />
            </div>
            <div style="margin-left: 10px">
              <div>
                <span>{{ pageData.year_power }}</span> (kWh)
              </div>
              <div>当年发电量</div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="center-box" style="border: 0px solid #ccc">
            <div>
              <el-image :src="require('@/assets/solarPower/zifa.png')" fit="fill" />
            </div>
            <div style="margin-left: 10px">
              <div>
                <span>{{ pageData.total_power }}</span> (kWh)
              </div>
              <div>总发电量</div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    pageData: {
      type: Object,
      default: () => {},
    },
  },
  name: "overviewHead",
  data() {
    return {
      date: null,
      nowTimer: null,
      headData: null,
    };
  },
  watch: {
    pageData: {
      // deep: true,
      // immediate: true,
      handler(val) {
        this.headData = val;
        // console.log(2222, val);
        // console.log("this.headData", this.headData);
      },
    },
  },
  created() {
    this.nowTimer = setInterval(this.getTime, 1000);
  },
  mounted() {
    this.getTime();
  },
  methods: {
    getTime() {
      let weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
      // HH:mm:ss
      this.date =
        weeks[this.dayjs().day()] + "    " + this.dayjs().format("YYYY/MM/DD HH:mm:ss");
    },
  },
  // 销毁定时器
  beforeDestroy() {
    if (this.nowTimer) {
      clearInterval(this.nowTimer);
    }
  },
};
</script>
<style lang="scss" scoped>
.head-title-warp {
  display: flex;
  justify-content: space-between;
  .head-title-left {
    flex: 1;
    display: flex;
    align-items: center;
    .title-left-bg {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      background-color: rgb(237, 237, 237);
      line-height: 45px;
      text-align: center;
    }
    .title-left-word {
      margin-left: 5px;
      font-size: 18px;
      font-weight: bold;
    }
  }
  .head-title-right {
    display: flex;
    align-items: center;
    justify-content: center;
    .title-right-box1 {
      .el-image {
        width: 30px;
        height: 30px;
      }
      width: 40px;
      font-size: 16px;
    }
    .title-right-box2 {
      width: 240px;
      margin-left: 10px;
    }
  }
}
.head-title-center {
  width: 100%;
  height: 100px;
  border: 1px solid #dfdfdf;
  border-radius: 4px;
  margin-top: 10px;
  .center-box {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #777;
    word-break: normal;
    font-size: 14px;
    height: 100px;
    border-right: #dfdfdf 1px solid;
    div {
      span {
        font-size: 20px;
        font-weight: bold;
        color: #000;
      }
    }
    .el-image {
      width: 60px;
      height: 60px;
      // margin-top: 35px;
    }
  }
}
</style>
